import requests, random

# 登陆
s = requests.Session()
data = 'username=admin&password=admin123&verifycode=0000'
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
r = s.post('http://localhost:8081/WoniuSales1.4/user/login', data=data, headers=headers)
print(r.text)

# 添加会员
sequence = random.randint(10000, 99999)
data = 'customername=用户_%d&customerphone=138000%d&childsex=男&childdate=2018-10-09&creditkids=11&creditcloth=22' % (
sequence, sequence)
# data= {'customername': '小王子11', 'customerphone': '13800001123', 'childsex': '男', 'childdate': '2018-10-09',
#                 'creditkids': '11', 'creditcloth': '22'}
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
r = s.post('http://localhost:8081/WoniuSales1.4/customer/add', data=data.encode(), headers=headers)
print(r.text)

# #查询会员
# data = 'customerphone=138000%d&page=a.txt'%sequence
# headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
# r = s.post('http://localhost:8081/WoniuSales1.4/customer/search', data=data, headers = headers)
# print(r.json()[0]['customerphone'])
